package com.compomics.prioritizer.general.gui;

import com.compomics.prioritizer.db.accessors.*;
import com.compomics.prioritizer.db.accessors.Label;
import com.compomics.prioritizer.general.ArrayListComboBoxModel;
import com.compomics.prioritizer.general.PrioritizerSingelton;
import org.apache.commons.collections.CollectionUtils;
//import junit.framework.Test;

import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;
import java.text.SimpleDateFormat;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Niklaas Colaert
 * Date: 5-dec-2008
 * Time: 9:58:39
 * To change this template use File | Settings | File Templates.
 */
public class ProjectPanelGui {
    private JPanel projectInfoPanel;
    private JTextField txtTitle;
    private JTextField txtUser;
    private JTextArea txtDescription;
    private JTextField txtCreated;
    private JTextField txtAccepted;
    private JButton projectDoneButton;
    private JComboBox cmbProtocol;
    private JList listVarMod;
    private JComboBox cmbLabel;
    private JComboBox cmbTaxonomy;
    private JButton saveProjectChangesButton;
    private JLabel lblModifcation;
    private JComboBox cmbModification;
    private JButton addButton1;
    private JList listFixMod;
    private JButton addButton;
    private JButton deleteButton;
    private JButton deleteButton1;
    private JPanel jpanContent;
    private JButton createProjectButton;
    private JButton acceptProjectButton;
    private JTextField txtInstrumentProposed;
    private JComboBox cmbInstrumentAccepted;
    private JTextField txtInstrumentAccepted;
    private JComboBox cmbProject;
    private JLabel lblInstrumentAccepted;
    private JLabel lblProjectAccepted;
    private JLabel lblProjectCreated;
    private JLabel lblProjectUser;
    private JLabel lblSelectProjects;
    private JComboBox cmbInstrumentProposed;
    private JProgressBar progressBar1;
    private JComboBox cmbStatus;
    private JButton changeStatusButton;
    private JLabel lblStatus;
    private JScrollPane scollOldStatus;
    private JTextArea txtOldStatus;
    private JLabel lblOldStatus;
    private JComboBox cmbProjectType;
    private JLabel lblProjectType;

    //the connection
    private Connection iConnPriority;
    //the Instruments
    private Instrument[] iInstruments;
    //the Protocols
    private Protocol[] iProtocols;
    //the Modifications
    private Modification[] iModifications;
    //the fixed Modifications
    private Vector fixedMods;
    //the variable Modifications
    private Vector varMods;
    //the taxonomies
    private Taxonomy[] iTaxonomies;
    //the labels
    private Label[] iLabels;
    //the Project types
    private ProjectType[] iProjectTypes;
    private ArrayListComboBoxModel iProjectModel;

    /**
     * Date-time format String.
     */
    private static final String iDateTimeFormat = "dd/MM/yyyy - HH:mm:ss";
    /**
     * The SimpleDateFormat formatter to display creationdates.
     */
    private static SimpleDateFormat iSDF = new SimpleDateFormat(iDateTimeFormat);
    private int iMode;
    private Project iProject;
    private JFrame iParent;
    private User iUser;
    private boolean iProjectModificationsChanged;
    private int iRole;
    private ArrayList<Project> iProjects;
    private boolean iChangesDone;
    private JList iParentProjectList;
    private PrioritizerSingelton iPrioritizerSingelton;

    public ProjectPanelGui(Connection aConn, int aMode, Project aProject, JFrame aParent, User aUser, Project[] aProjects, JList aParentProjectList) {
        this.iConnPriority = aConn;
        this.iMode = aMode;
        this.iProject = aProject;
        this.iParent = aParent;
        this.iUser = aUser;
        this.iRole = iUser.getRole();
        iPrioritizerSingelton = PrioritizerSingelton.getInstance();

        this.iProjects = new ArrayList<Project>();
        if (aProjects != null) {
            for (int a = 0; a < aProjects.length; a++) {
                iProjects.add(aProjects[a]);
            }
        }
        this.iParentProjectList = aParentProjectList;
        $$$setupUI$$$();

        createProjectButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                createProject();
            }
        });
        addButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                addFixedMod();
            }
        });
        addButton1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                addVarMod();
            }
        });
        cmbProtocol.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    protocolChanged((Protocol) e.getItem(), iProject);
                }
            }
        });
        deleteButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                deleteFixedMod();
            }
        });
        deleteButton1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                deleteVarMod();
            }
        });
        saveProjectChangesButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                saveProjectChanges();
            }
        });
        cmbProject.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    iProject = (Project) e.getItem();
                    loadProject(iProject);
                }
            }
        });
        projectDoneButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                projectDone();
            }
        });
        acceptProjectButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                acceptProject();
            }
        });
        changeStatusButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                changeStatus();
            }
        });

        //show the correct things in the correct mode
        //mode 1 (create a project)
        if (iMode == 1) {
            cmbInstrumentAccepted.setVisible(false);
            lblInstrumentAccepted.setVisible(false);
            lblProjectAccepted.setVisible(false);
            txtAccepted.setVisible(false);
            cmbInstrumentAccepted.setVisible(false);
            txtInstrumentAccepted.setVisible(false);
            txtInstrumentProposed.setVisible(false);
            lblProjectCreated.setVisible(false);
            txtCreated.setVisible(false);
            txtUser.setVisible(false);
            lblProjectUser.setVisible(false);
            lblSelectProjects.setVisible(false);
            cmbProject.setVisible(false);
            projectDoneButton.setVisible(false);
            acceptProjectButton.setVisible(false);
            saveProjectChangesButton.setVisible(false);
            changeStatusButton.setVisible(false);
            cmbStatus.setVisible(false);
            lblStatus.setVisible(false);
            lblOldStatus.setVisible(false);
            scollOldStatus.setVisible(false);
            txtOldStatus.setVisible(false);
        }
        //edit and project done mode
        if (iMode == 2) {
            createProjectButton.setVisible(false);
            acceptProjectButton.setVisible(false);
            lblSelectProjects.setVisible(false);
            cmbProject.setVisible(false);
            cmbInstrumentAccepted.setVisible(false);
            txtInstrumentAccepted.setVisible(false);
            lblInstrumentAccepted.setVisible(false);
            cmbInstrumentProposed.setVisible(false);
            txtInstrumentProposed.setEditable(false);
            cmbProjectType.setVisible(false);
            lblProjectType.setVisible(false);
        }
        //accept mode
        if (iMode == 3) {
            createProjectButton.setVisible(false);
            projectDoneButton.setVisible(false);
            saveProjectChangesButton.setVisible(false);
            txtAccepted.setVisible(false);
            lblProjectAccepted.setVisible(false);
            txtTitle.setEditable(false);
            txtDescription.setEditable(false);
            txtInstrumentProposed.setEditable(false);
            txtInstrumentAccepted.setVisible(false);
            cmbInstrumentProposed.setVisible(false);
            cmbLabel.setEditable(false);
            cmbTaxonomy.setEditable(false);
            cmbModification.setEditable(false);
            cmbProtocol.setEditable(false);
            addButton.setVisible(false);
            addButton1.setVisible(false);
            deleteButton.setVisible(false);
            deleteButton1.setVisible(false);
            changeStatusButton.setVisible(false);
            cmbStatus.setVisible(false);
            lblStatus.setVisible(false);
            lblOldStatus.setVisible(false);
            scollOldStatus.setVisible(false);
            txtOldStatus.setVisible(false);
            cmbProjectType.setVisible(false);
            lblProjectType.setVisible(false);
        }
        progressBar1.setVisible(false);

        if (iProjects.size() != 0) {
            iProject = iProjects.get(0);
            iProjectModel.setSelectedItem(iProject);
        }
        loadProject(iProject);


    }

    public void changeStatus() {
        String lStatus = (String) cmbStatus.getSelectedItem();
        saveStatus(iProject, lStatus);
    }

    public void showProgressBar() {
        progressBar1.setVisible(true);
        progressBar1.setIndeterminate(true);
        progressBar1.updateUI();
        this.iParent.update(this.iParent.getGraphics());
        progressBar1.updateUI();
    }

    public void stopProgressBar() {
        progressBar1.setIndeterminate(false);
        progressBar1.setVisible(false);
        this.iParent.update(this.iParent.getGraphics());
    }

    public void acceptProject() {
        Instrument instrument = (Instrument) cmbInstrumentAccepted.getSelectedItem();
        try {
            if (iProject != null) {
                int priority = 1 + instrument.getLowestPriority(iConnPriority);
                long instrumentId = instrument.getInstrumentid();
                iProject.setPriority(priority);
                iProject.setL_instrumentid_accepted(instrumentId);
                iProject.updateAcceptedProject(iConnPriority);
                this.saveStatus(iProject, "accepted");
                MailSendingPanel lMail = new MailSendingPanel();
                iPrioritizerSingelton.addMailSendingPanel(lMail);
                lMail.projectAccepted(iConnPriority, iProject);
                JOptionPane.showMessageDialog(iParent, "You succesfully accepted a project", "Project accepted", JOptionPane.INFORMATION_MESSAGE);


                findNewProjects();
            } else {
                JOptionPane.showMessageDialog(iParent, "No or an old project is selected, could not save this project!", "Project not saved", JOptionPane.INFORMATION_MESSAGE);
            }

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public JPanel getContentPane() {
        return jpanContent;
    }

    public void projectDone() {
        this.showProgressBar();
        if (iProject != null) {
            try {
                //set priority to zero (=project done)
                iProject.setPriority(0);
                //get the used instrument
                Instrument lUsedInstrument = Instrument.getInstrumentById(iConnPriority, iProject.getL_instrumentid_accepted());
                iProject.setDescription(iProject.getDescription() + "\n This project was done on " + lUsedInstrument.getName());
                //set the instrument to old instrument
                for (int i = 0; i < iInstruments.length; i++) {
                    if (iInstruments[i].getDescription().equalsIgnoreCase("Old projects")) {
                        iProject.setL_instrumentid_accepted(iInstruments[i].getInstrumentid());
                    }
                }
                iProject.updateProjectDone(iConnPriority);
                this.saveStatus(iProject, "Done");
                MailSendingPanel lMail = new MailSendingPanel();
                iPrioritizerSingelton.addMailSendingPanel(lMail);
                lMail.projectDone(iConnPriority, iProject);
                //get the the projects for the selected instrument
                Project[] lProjects = Project.getAllUnfinishedProjectsForInstrument(iConnPriority, ((Instrument) cmbInstrumentAccepted.getSelectedItem()).getInstrumentid());
                System.out.println("iProjects size: " + iProjects.size() + ", selectedIndex " + iParentProjectList.getSelectedIndex());
                iProjects.remove(iParentProjectList.getSelectedIndex());
                //iProjects.remove(iParentProjectList.getSelectedValue());
                iParentProjectList.setListData(lProjects);
                projectDoneButton.setEnabled(false);
                //save the new priorities
                storeProjectPriorityChanges();
            } catch (SQLException e) {
                JOptionPane.showMessageDialog(iParent, new String[]{"Unable to set project done:  ", e.getMessage()}, "Error!", JOptionPane.ERROR_MESSAGE);
            }
        }

        this.stopProgressBar();

    }

    public void storeProjectPriorityChanges() {
        this.showProgressBar();
        for (int p = 0; p < iProjects.size(); p++) {
            Project lProject = iProjects.get(p);
            long oldPriority = lProject.getPriority();
            if (p + 1 != lProject.getPriority()) {
                lProject.setPriority(p + 1);
                try {
                    lProject.updatePriorityProject(iConnPriority);
                    if (oldPriority != 1 && lProject.getPriority() == 1) {
                        MailSendingPanel lMail = new MailSendingPanel();
                        iPrioritizerSingelton.addMailSendingPanel(lMail);
                        lMail.projectTopPriority(iConnPriority, lProject);
                    }
                } catch (SQLException e) {
                    JOptionPane.showMessageDialog(iParent, new String[]{"Unable to store changed priority:  ", e.getMessage()}, "Error!", JOptionPane.ERROR_MESSAGE);
                }
            }

        }
        // an e-mail is sent if the admin changes the priorities, not if the mass spec operator changes it
        if (iRole == 2) {
            MailSendingPanel lMail = new MailSendingPanel();
            iPrioritizerSingelton.addMailSendingPanel(lMail);
            lMail.prioritiesChanged(iConnPriority, iProject.getL_instrumentid_accepted());
        }
        iChangesDone = false;
        this.stopProgressBar();
    }

    public void saveProjectChanges() {
        this.showProgressBar();
        iProject.setDescription(txtDescription.getText());
        iProject.setName(txtTitle.getText());
        iProject.setL_labelid(((Label) cmbLabel.getSelectedItem()).getLabelid());
        iProject.setL_protocolid(((Protocol) cmbProtocol.getSelectedItem()).getProtocolid());
        iProject.setL_taxonomyid(((Taxonomy) cmbTaxonomy.getSelectedItem()).getTaxonomyid());
        try {
            iProject.update(iConnPriority);
            if (iProjectModificationsChanged) {
                Modification_link.deleteAllModificationsForProject(iConnPriority, iProject.getProjectid());
                this.storeModifications(iProject.getProjectid());
            }
            MailSendingPanel lMail = new MailSendingPanel();
            iPrioritizerSingelton.addMailSendingPanel(lMail);
            lMail.projectModified(iConnPriority, iProject);
            JOptionPane.showMessageDialog(iParent, "Saved project updates succesfully!", "Project updates saved!", JOptionPane.INFORMATION_MESSAGE);
        } catch (SQLException e) {
            JOptionPane.showMessageDialog(iParent, new String[]{"Unable to save project updates:  ", e.getMessage()}, "Error!", JOptionPane.ERROR_MESSAGE);
        }
        this.stopProgressBar();
    }

    public void addFixedMod() {
        Modification addMod = (Modification) cmbModification.getSelectedItem();
        fixedMods.add(addMod);
        if (fixedMods.size() > 0) {
            deleteButton.setEnabled(true);
        } else {
            deleteButton.setEnabled(false);
        }
        listFixMod.setSelectedIndex(0);
        listFixMod.updateUI();
        iProjectModificationsChanged = true;
    }

    public void addVarMod() {
        Modification addMod = (Modification) cmbModification.getSelectedItem();
        varMods.add(addMod);
        if (varMods.size() > 0) {
            deleteButton1.setEnabled(true);
        } else {
            deleteButton1.setEnabled(false);
        }

        listVarMod.setSelectedIndex(0);
        listVarMod.updateUI();
        iProjectModificationsChanged = true;
    }

    public void deleteFixedMod() {
        Modification delMod = (Modification) listFixMod.getSelectedValue();
        fixedMods.remove(delMod);
        if (fixedMods.size() > 0) {
            deleteButton.setEnabled(true);
        } else {
            deleteButton.setEnabled(false);
        }
        listFixMod.setSelectedIndex(0);
        listFixMod.updateUI();
        iProjectModificationsChanged = true;
    }

    public void deleteVarMod() {
        Modification delMod = (Modification) listVarMod.getSelectedValue();
        varMods.remove(delMod);
        if (varMods.size() > 0) {
            deleteButton1.setEnabled(true);
        } else {
            deleteButton1.setEnabled(false);
        }
        listVarMod.setSelectedIndex(0);
        listVarMod.updateUI();
        iProjectModificationsChanged = true;
    }

    public void storeModifications(long aProjectId) {
        //store fixed modifications
        for (int f = 0; f < fixedMods.size(); f++) {
            HashMap hm = new HashMap(3);
            hm.put(Modification_link.PROJECT, 1);
            hm.put(Modification_link.PROTOCOL, 0);
            //type is 1 for fixed
            hm.put(Modification_link.TYPE, 1);
            hm.put(Modification_link.L_MODIFICATIONID, ((Modification) fixedMods.get(f)).getModificationid());
            hm.put(Modification_link.L_LINKID, aProjectId);

            Modification_link lModification_link = new Modification_link(hm);
            try {
                lModification_link.persist(iConnPriority);
            } catch (SQLException e) {
                JOptionPane.showMessageDialog(iParent, new String[]{"Unable to store modifications for this project:  ", e.getMessage()}, "Error!", JOptionPane.ERROR_MESSAGE);
            }
        }

        //store variable modifications
        for (int f = 0; f < varMods.size(); f++) {
            HashMap hm = new HashMap(3);
            hm.put(Modification_link.PROJECT, 1);
            hm.put(Modification_link.PROTOCOL, 0);
            //type is 0 for variable
            hm.put(Modification_link.TYPE, 0);
            hm.put(Modification_link.L_MODIFICATIONID, ((Modification) varMods.get(f)).getModificationid());
            hm.put(Modification_link.L_LINKID, aProjectId);


            Modification_link lModification_link = new Modification_link(hm);
            try {
                lModification_link.persist(iConnPriority);
            } catch (SQLException e) {
                JOptionPane.showMessageDialog(iParent, new String[]{"Unable to store modifications for this project:  ", e.getMessage()}, "Error!", JOptionPane.ERROR_MESSAGE);
            }
        }


    }

    public void protocolChanged(Protocol aProtocol, Project aProject) {
        if (aProtocol.getName().equalsIgnoreCase("User specific protocol")) {
            addButton.setEnabled(true);
            addButton1.setEnabled(true);
            deleteButton.setEnabled(true);
            deleteButton1.setEnabled(true);
            cmbModification.setEnabled(true);


            Modification[] fix = new Modification[0];
            Modification[] var = new Modification[0];
            if (aProject != null) {
                try {
                    fix = Modification_link.getProjectFixedModification_links(iConnPriority, aProject.getProjectid());
                    var = Modification_link.getProjectVariableModification_links(iConnPriority, aProject.getProjectid());
                } catch (SQLException e) {
                    JOptionPane.showMessageDialog(iParent, new String[]{"Unable to load modifications for project:  ", e.getMessage()}, "Error!", JOptionPane.ERROR_MESSAGE);
                }
            }
            this.loadModifications(fix, var);

        } else {
            addButton.setEnabled(false);
            addButton1.setEnabled(false);
            deleteButton.setEnabled(false);
            deleteButton1.setEnabled(false);
            cmbModification.setEnabled(false);

            Modification[] fix = new Modification[0];
            Modification[] var = new Modification[0];
            try {
                fix = Modification_link.getProtocolFixedModification_links(iConnPriority, aProtocol.getProtocolid());
                var = Modification_link.getProtocolVariableModification_links(iConnPriority, aProtocol.getProtocolid());
            } catch (SQLException e) {
                JOptionPane.showMessageDialog(iParent, new String[]{"Unable to load modificatoins for protocol:  ", e.getMessage()}, "Error!", JOptionPane.ERROR_MESSAGE);
            }

            this.loadModifications(fix, var);
        }
    }

    private void loadModifications(Modification[] lFixed, Modification[] lVariable) {
        fixedMods.removeAllElements();
        varMods.removeAllElements();
        for (int f = 0; f < lFixed.length; f++) {
            fixedMods.add(lFixed[f]);
        }
        for (int f = 0; f < lVariable.length; f++) {
            varMods.add(lVariable[f]);
        }
        listFixMod.updateUI();
        listVarMod.updateUI();
    }

    private void createUIComponents() {
        this.gatherData();
        cmbProjectType = new JComboBox(iProjectTypes);
        cmbInstrumentAccepted = new JComboBox(iInstruments);
        cmbInstrumentProposed = new JComboBox(iInstruments);
        cmbModification = new JComboBox(iModifications);
        cmbTaxonomy = new JComboBox(iTaxonomies);
        cmbProtocol = new JComboBox(iProtocols);
        String[] lStatus = new String[]{"Accepted", "Running", "Hold", "Spectra stored", "Searching", "Identifications stored", "Doing quantitation", "Quantitation stored", "Done"};
        cmbStatus = new JComboBox(lStatus);
        varMods = new Vector();
        fixedMods = new Vector();
        listVarMod = new JList(varMods);
        listFixMod = new JList(fixedMods);
        cmbLabel = new JComboBox(iLabels);
        if (iProjects == null) {
            cmbProject = new JComboBox();
        } else {
            iProjectModel = new ArrayListComboBoxModel(iProjects);
            cmbProject = new JComboBox(iProjectModel);
        }
    }

    public void loadProject(Project aProject) {
        try {
            if (aProject != null) {
                iProject = aProject;
                txtTitle.setText(aProject.getName());
                txtDescription.setText(aProject.getDescription());
                long instrumentid = aProject.getL_instrumentid_proposed();
                Instrument lInstrumentProposed = Instrument.getInstrumentById(iConnPriority, instrumentid);
                txtInstrumentProposed.setText(lInstrumentProposed.getName());
                long userid = aProject.getL_userid();
                User lUser = User.getUserById(iConnPriority, userid);
                txtUser.setText(lUser.getName());
                txtCreated.setText(iSDF.format(aProject.getCreationdate()));
                if (iMode != 3) {
                    txtAccepted.setText(iSDF.format(aProject.getAccepteddate()));
                }
                //set the modifications for this project
                fixedMods.removeAllElements();
                varMods.removeAllElements();
                for (int p = 0; p < iProtocols.length; p++) {
                    if (iProtocols[p].getProtocolid() == aProject.getL_protocolid()) {
                        cmbProtocol.setSelectedIndex(p);
                        //protocolChanged(iProtocols[p], aProject);
                    }
                }
                for (int p = 0; p < iTaxonomies.length; p++) {
                    if (iTaxonomies[p].getTaxonomyid() == aProject.getL_taxonomyid()) {
                        cmbTaxonomy.setSelectedIndex(p);
                    }
                }
                for (int p = 0; p < iLabels.length; p++) {
                    if (iLabels[p].getLabelid() == aProject.getL_labelid()) {
                        cmbLabel.setSelectedIndex(p);
                    }
                }
                projectDoneButton.setEnabled(true);

                //only show status in mode 2
                if (iMode == 2) {
                    //show the current status
                    Log lLog = Log.getNewestLogForProject(iConnPriority, aProject.getProjectid());
                    if (lLog != null) {
                        for (int i = 0; i < cmbStatus.getItemCount(); i++) {
                            if (lLog.getStatus().equalsIgnoreCase(cmbStatus.getItemAt(i).toString())) {
                                cmbStatus.setSelectedIndex(i);
                            }
                        }
                    }
                    //show the old status
                    Log[] lLogs = Log.getAllLogsForProject(iConnPriority, aProject.getProjectid());
                    txtOldStatus.setText("");
                    for (int i = 0; i < lLogs.length - 1; i++) {
                        txtOldStatus.append(" " + lLogs[i].getCreationdate() + "  :  " + lLogs[i].getStatus() + "\n");
                    }
                }

                boolean lIsUserOfInstrument = Boolean.FALSE;
                List<Long> lUserIds = Instrument_to_user.getUserIdsByInstumentId(iConnPriority, aProject.getL_instrumentid_accepted());
                if (lUserIds.contains(iUser.getUserid())) {
                    lIsUserOfInstrument = Boolean.TRUE;
                }
                if (iMode == 2 && lIsUserOfInstrument) {
                    this.projectDoneButton.setVisible(true);
                    this.cmbStatus.setEnabled(true);
                    this.changeStatusButton.setVisible(true);
                } else {
                    this.changeStatusButton.setVisible(false);
                    this.projectDoneButton.setVisible(false);
                    this.cmbStatus.setEnabled(false);
                }

                if (iUser.getUserid() == iProject.getL_userid() && iMode == 2) {
                    cmbLabel.setEnabled(true);
                    cmbTaxonomy.setEnabled(true);
                    cmbProtocol.setEnabled(true);
                    txtDescription.setEditable(true);
                    txtTitle.setEditable(true);
                    saveProjectChangesButton.setVisible(true);
                    lblModifcation.setVisible(true);
                    cmbModification.setVisible(true);
                    addButton.setVisible(true);
                    addButton1.setVisible(true);
                    deleteButton1.setVisible(true);
                    deleteButton.setVisible(true);
                } else {
                    cmbLabel.setEnabled(false);
                    cmbTaxonomy.setEnabled(false);
                    cmbProtocol.setEnabled(false);
                    txtDescription.setEditable(false);
                    txtTitle.setEditable(false);
                    saveProjectChangesButton.setVisible(false);
                    lblModifcation.setVisible(false);
                    cmbModification.setVisible(false);
                    addButton.setVisible(false);
                    addButton1.setVisible(false);
                    deleteButton1.setVisible(false);
                    deleteButton.setVisible(false);
                }
            } else {
                txtInstrumentProposed.setText("");
                txtAccepted.setText("");
                txtCreated.setText("");
                txtDescription.setText("");
                txtInstrumentAccepted.setText("");
                txtTitle.setText("");
                txtUser.setText("");
                txtOldStatus.setText("");
            }
        } catch (SQLException sqle) {
            sqle.printStackTrace();
            JOptionPane.showMessageDialog(iParent, new String[]{"Unable to find projects information:  ", sqle.getMessage()}, "Error!", JOptionPane.ERROR_MESSAGE);
        }
    }


    public void saveStatus(Project aProject, String lStatus) {
        try {
            HashMap hm = new HashMap();
            hm.put(Log.STATUS, lStatus);
            hm.put(Log.L_PROJECTID, aProject.getProjectid());

            Log lLog = new Log(hm);
            lLog.persist(iConnPriority);
            //only if this is not a new project
            if (!lStatus.equalsIgnoreCase("created")) {
                MailSendingPanel lMail = new MailSendingPanel();
                iPrioritizerSingelton.addMailSendingPanel(lMail);
                lMail.projectStatusChanged(iConnPriority, aProject);
            }
        } catch (SQLException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            return;
        }
        JOptionPane.showMessageDialog(iParent, "You succesfully changed the status", "Project status changed", JOptionPane.INFORMATION_MESSAGE);

    }

    /**
     * This method gets all data from the GUI components and creates a project.
     */
    public void createProject() {
        this.showProgressBar();
        HashMap hm = null;
        // Get the data in the textfields.
        String lTitle = txtTitle.getText().trim();
        Instrument lInstrument = (Instrument) cmbInstrumentProposed.getSelectedItem();
        ProjectType pt = (ProjectType) cmbProjectType.getSelectedItem();
        String lDescription = txtDescription.getText();

        // See if the not-NULL fields are filled out.
        if (lTitle.equals("")) {
            JOptionPane.showMessageDialog(iParent, "Project title must be filled out!", "Title has to be filled out!", JOptionPane.WARNING_MESSAGE);
            txtTitle.requestFocus();
        } else {

            Protocol prot = (Protocol) cmbProtocol.getSelectedItem();
            Label label = (Label) cmbLabel.getSelectedItem();
            Taxonomy tax = (Taxonomy) cmbTaxonomy.getSelectedItem();
            // Creation of the param HashMap.
            hm = new HashMap();
            hm.put(Project.NAME, lTitle);
            //hm.put(Project.)
            hm.put(Project.DESCRIPTION, lDescription);
            hm.put(Project.L_INSTRUMENTID_PROPOSED, lInstrument.getInstrumentid());
            hm.put(Project.L_USERID, iUser.getUserid());
            hm.put(Project.L_PROTOCOLID, prot.getProtocolid());
            hm.put(Project.L_TAXONOMYID, tax.getTaxonomyid());
            hm.put(Project.L_LABELID, label.getLabelid());
            hm.put(Project.L_PROJECT_TYPEID, pt.getProject_typeid());


            Project lProject = new Project(hm);
            try {
                lProject.createNewProject(iConnPriority);
                this.saveStatus(lProject, "created");
                Protocol aProtocol = (Protocol) cmbProtocol.getSelectedItem();
                if (aProtocol.getName().equalsIgnoreCase("User specific protocol")) {
                    this.storeModifications(lProject.getProjectid());
                }
                MailSendingPanel lMail = new MailSendingPanel();
                iPrioritizerSingelton.addMailSendingPanel(lMail);
                lMail.newProject(iConnPriority, lProject);
            } catch (SQLException e) {
                JOptionPane.showMessageDialog(iParent, "Project could not be stored!\n" + e.getMessage(), "ERROR", JOptionPane.WARNING_MESSAGE);
                return;
            }
            JOptionPane.showMessageDialog(iParent, "You succesfully created a project", "Project created", JOptionPane.INFORMATION_MESSAGE);
            this.iParent.dispose();
        }
        this.stopProgressBar();
    }


    public void gatherData() {
        this.findInstruments();
        this.findModifications();
        this.findProtocols();
        this.findTaxonomies();
        this.findLabels();
        this.findProjectTypes();
    }

    /**
     * This method collects all project types.
     * It fills the 'iProjectTypes' cache.
     */
    private void findProjectTypes() {
        try {
            iProjectTypes = ProjectType.getAllProjectTypes(iConnPriority);
        } catch (SQLException sqle) {
            JOptionPane.showMessageDialog(iParent, new String[]{"Unable to find project types:  ", sqle.getMessage()}, "Error!", JOptionPane.ERROR_MESSAGE);
        }
    }

    /**
     * This method collects all instruments.
     * It fills the 'iInstruments' cache.
     */
    private void findInstruments() {
        try {
            iInstruments = Instrument.getAllInstruments(iConnPriority);
        } catch (SQLException sqle) {
            JOptionPane.showMessageDialog(iParent, new String[]{"Unable to find instruments:  ", sqle.getMessage()}, "Error!", JOptionPane.ERROR_MESSAGE);
        }
    }


    /**
     * This method collects all taxonomies.
     * It fills the 'iTaxonomies' cache.
     */
    private void findTaxonomies() {
        try {
            iTaxonomies = Taxonomy.getAllTaxonomys(iConnPriority);
        } catch (SQLException sqle) {
            JOptionPane.showMessageDialog(iParent, new String[]{"Unable to find taxonomy:  ", sqle.getMessage()}, "Error!", JOptionPane.ERROR_MESSAGE);
        }
    }


    /**
     * This method collects all labels.
     * It fills the 'iLabels' cache.
     */
    private void findLabels() {
        try {
            iLabels = Label.getAllLabels(iConnPriority);
        } catch (SQLException sqle) {
            JOptionPane.showMessageDialog(iParent, new String[]{"Unable to find labels:  ", sqle.getMessage()}, "Error!", JOptionPane.ERROR_MESSAGE);
        }
    }

    /**
     * This method collects all protocols.
     * It fills the 'iProtocol' cache.
     */
    private void findProtocols() {
        try {
            iProtocols = Protocol.getAllProtocols(iConnPriority);
        } catch (SQLException sqle) {
            JOptionPane.showMessageDialog(iParent, new String[]{"Unable to find protocols:  ", sqle.getMessage()}, "Error!", JOptionPane.ERROR_MESSAGE);
        }
    }

    /**
     * This method collects all modifications.
     * It fills the 'iModifications' cache.
     */
    private void findModifications() {
        try {
            iModifications = Modification.getAllModifications(iConnPriority);
        } catch (SQLException sqle) {
            JOptionPane.showMessageDialog(iParent, new String[]{"Unable to find modifications:  ", sqle.getMessage()}, "Error!", JOptionPane.ERROR_MESSAGE);
        }
    }

    private void findNewProjects() {

        iProjectModel.removeElement(iProject);
        if (iProjectModel.getSize() == 0) {
            JOptionPane.showMessageDialog(iParent, "No new projects found!", "No projects found", JOptionPane.INFORMATION_MESSAGE);
            iProject = null;
        } else {
            iProject = (Project) iProjectModel.getElementAt(0);
        }
        iProjectModel.setSelectedItem(iProject);
        loadProject(iProject);


    }

    /**
     * Method generated by IntelliJ IDEA GUI Designer
     * >>> IMPORTANT!! <<<
     * DO NOT edit this method OR call it in your code!
     *
     * @noinspection ALL
     */
    private void $$$setupUI$$$() {
        createUIComponents();
        jpanContent = new JPanel();
        jpanContent.setLayout(new GridBagLayout());
        projectInfoPanel = new JPanel();
        projectInfoPanel.setLayout(new GridBagLayout());
        GridBagConstraints gbc;
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.gridheight = 2;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        jpanContent.add(projectInfoPanel, gbc);
        projectInfoPanel.setBorder(BorderFactory.createTitledBorder(null, "Project info", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.ABOVE_TOP, new Font(projectInfoPanel.getFont().getName(), projectInfoPanel.getFont().getStyle(), 16)));
        final JLabel label1 = new JLabel();
        label1.setText("Project name:");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(label1, gbc);
        txtTitle = new JTextField();
        txtTitle.setEditable(true);
        txtTitle.setEnabled(true);
        gbc = new GridBagConstraints();
        gbc.gridx = 6;
        gbc.gridy = 1;
        gbc.gridwidth = 5;
        gbc.weightx = 1.0;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(txtTitle, gbc);
        txtUser = new JTextField();
        txtUser.setEditable(false);
        gbc = new GridBagConstraints();
        gbc.gridx = 6;
        gbc.gridy = 8;
        gbc.gridwidth = 5;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(txtUser, gbc);
        lblProjectUser = new JLabel();
        lblProjectUser.setText("Project user: ");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 8;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(lblProjectUser, gbc);
        final JScrollPane scrollPane1 = new JScrollPane();
        gbc = new GridBagConstraints();
        gbc.gridx = 6;
        gbc.gridy = 3;
        gbc.gridwidth = 5;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(scrollPane1, gbc);
        txtDescription = new JTextArea();
        txtDescription.setColumns(0);
        txtDescription.setEditable(true);
        txtDescription.setEnabled(true);
        txtDescription.setRows(3);
        scrollPane1.setViewportView(txtDescription);
        final JLabel label2 = new JLabel();
        label2.setText("Project description:");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 3;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(label2, gbc);
        lblProjectCreated = new JLabel();
        lblProjectCreated.setText("Project created:");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 9;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(lblProjectCreated, gbc);
        lblProjectAccepted = new JLabel();
        lblProjectAccepted.setText("Project accepted:");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 10;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(lblProjectAccepted, gbc);
        txtCreated = new JTextField();
        txtCreated.setEditable(false);
        gbc = new GridBagConstraints();
        gbc.gridx = 6;
        gbc.gridy = 9;
        gbc.gridwidth = 5;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(txtCreated, gbc);
        txtAccepted = new JTextField();
        txtAccepted.setEditable(false);
        gbc = new GridBagConstraints();
        gbc.gridx = 6;
        gbc.gridy = 10;
        gbc.gridwidth = 5;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(txtAccepted, gbc);
        projectDoneButton = new JButton();
        projectDoneButton.setText("Project done");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 26;
        gbc.gridwidth = 11;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(projectDoneButton, gbc);
        final JLabel label3 = new JLabel();
        label3.setText("Protocol:");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 13;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(label3, gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 6;
        gbc.gridy = 13;
        gbc.gridwidth = 5;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(cmbProtocol, gbc);
        final JScrollPane scrollPane2 = new JScrollPane();
        gbc = new GridBagConstraints();
        gbc.gridx = 9;
        gbc.gridy = 21;
        gbc.gridwidth = 2;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(scrollPane2, gbc);
        scrollPane2.setViewportView(listVarMod);
        final JLabel label4 = new JLabel();
        label4.setText("Label:");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 11;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(0, 5, 0, 5);
        projectInfoPanel.add(label4, gbc);
        final JLabel label5 = new JLabel();
        label5.setText("Taxonomy:");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 12;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(0, 5, 0, 5);
        projectInfoPanel.add(label5, gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 6;
        gbc.gridy = 11;
        gbc.gridwidth = 5;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(cmbLabel, gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 6;
        gbc.gridy = 12;
        gbc.gridwidth = 5;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(cmbTaxonomy, gbc);
        saveProjectChangesButton = new JButton();
        saveProjectChangesButton.setText("Save project changes");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 23;
        gbc.gridwidth = 11;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(saveProjectChangesButton, gbc);
        lblModifcation = new JLabel();
        lblModifcation.setText("Modifications:");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 14;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(0, 5, 0, 5);
        projectInfoPanel.add(lblModifcation, gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 6;
        gbc.gridy = 14;
        gbc.gridwidth = 5;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(cmbModification, gbc);
        final JScrollPane scrollPane3 = new JScrollPane();
        gbc = new GridBagConstraints();
        gbc.gridx = 6;
        gbc.gridy = 21;
        gbc.gridwidth = 2;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(scrollPane3, gbc);
        scrollPane3.setViewportView(listFixMod);
        deleteButton = new JButton();
        deleteButton.setText("delete");
        gbc = new GridBagConstraints();
        gbc.gridx = 7;
        gbc.gridy = 20;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(deleteButton, gbc);
        createProjectButton = new JButton();
        createProjectButton.setText("Create project");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 25;
        gbc.gridwidth = 11;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(createProjectButton, gbc);
        acceptProjectButton = new JButton();
        acceptProjectButton.setText("Accept project");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 24;
        gbc.gridwidth = 11;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(acceptProjectButton, gbc);
        addButton = new JButton();
        addButton.setText("add");
        gbc = new GridBagConstraints();
        gbc.gridx = 6;
        gbc.gridy = 20;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(addButton, gbc);
        final JLabel label6 = new JLabel();
        label6.setText("Fixed modifications");
        gbc = new GridBagConstraints();
        gbc.gridx = 6;
        gbc.gridy = 19;
        gbc.gridwidth = 2;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(label6, gbc);
        addButton1 = new JButton();
        addButton1.setText("add");
        gbc = new GridBagConstraints();
        gbc.gridx = 9;
        gbc.gridy = 20;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(addButton1, gbc);
        deleteButton1 = new JButton();
        deleteButton1.setText("delete");
        gbc = new GridBagConstraints();
        gbc.gridx = 10;
        gbc.gridy = 20;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(deleteButton1, gbc);
        final JLabel label7 = new JLabel();
        label7.setText("Variable modifications");
        gbc = new GridBagConstraints();
        gbc.gridx = 9;
        gbc.gridy = 19;
        gbc.gridwidth = 2;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(label7, gbc);
        lblInstrumentAccepted = new JLabel();
        lblInstrumentAccepted.setText("Instrument accepted:");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 17;
        gbc.gridheight = 2;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(lblInstrumentAccepted, gbc);
        final JLabel label8 = new JLabel();
        label8.setText("Instrument proposed:");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 15;
        gbc.gridheight = 2;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(label8, gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 6;
        gbc.gridy = 17;
        gbc.gridwidth = 5;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(cmbInstrumentAccepted, gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 6;
        gbc.gridy = 0;
        gbc.gridwidth = 5;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(cmbProject, gbc);
        lblSelectProjects = new JLabel();
        lblSelectProjects.setText("Select a project:         ");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(lblSelectProjects, gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 6;
        gbc.gridy = 15;
        gbc.gridwidth = 5;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(cmbInstrumentProposed, gbc);
        txtInstrumentProposed = new JTextField();
        gbc = new GridBagConstraints();
        gbc.gridx = 6;
        gbc.gridy = 16;
        gbc.gridwidth = 5;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(txtInstrumentProposed, gbc);
        txtInstrumentAccepted = new JTextField();
        gbc = new GridBagConstraints();
        gbc.gridx = 6;
        gbc.gridy = 18;
        gbc.gridwidth = 5;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(txtInstrumentAccepted, gbc);
        progressBar1 = new JProgressBar();
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 22;
        gbc.gridwidth = 11;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(progressBar1, gbc);
        lblStatus = new JLabel();
        lblStatus.setText("Current status:");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 4;
        gbc.gridheight = 3;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(lblStatus, gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 6;
        gbc.gridy = 5;
        gbc.gridwidth = 5;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(cmbStatus, gbc);
        changeStatusButton = new JButton();
        changeStatusButton.setText("Change status");
        gbc = new GridBagConstraints();
        gbc.gridx = 6;
        gbc.gridy = 6;
        gbc.gridwidth = 5;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(changeStatusButton, gbc);
        lblOldStatus = new JLabel();
        lblOldStatus.setText("Old status:");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 7;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(lblOldStatus, gbc);
        scollOldStatus = new JScrollPane();
        gbc = new GridBagConstraints();
        gbc.gridx = 6;
        gbc.gridy = 7;
        gbc.gridwidth = 5;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(scollOldStatus, gbc);
        txtOldStatus = new JTextArea();
        txtOldStatus.setLineWrap(false);
        txtOldStatus.setRows(4);
        scollOldStatus.setViewportView(txtOldStatus);
        lblProjectType = new JLabel();
        lblProjectType.setText("Project type:");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 2;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(lblProjectType, gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 6;
        gbc.gridy = 2;
        gbc.gridwidth = 5;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        projectInfoPanel.add(cmbProjectType, gbc);
    }

    /**
     * @noinspection ALL
     */
    public JComponent $$$getRootComponent$$$() {
        return jpanContent;
    }
}
